#!/bin/ash -efu

ini_config_get_test1() { # UnitTest
	. ../shell-ini-config
	local result expect="Foo Bar"
	result="$(ini_config_get ini-config/z.ini global user)"
	assertEquals "$result" "$result" "$expect"
}

ini_config_get_test2() { # UnitTest
	. ../shell-ini-config
	local result expect="foo@bar"
	result="$(ini_config_get ini-config/z.ini global email)"
	assertEquals "$result" "$result" "$expect"
}

ini_config_get_test3() { # UnitTest
	. ../shell-ini-config
	local result expect="\"ZZZ XXX\""
	result="$(ini_config_get ini-config/z.ini sect opt)"
	assertEquals "$result" "$result" "$expect"
}

ini_config_get_test4() { # UnitTest
	. ../shell-ini-config
	local rc=0 result expect="$PROG: No such file or directory: ini-config/not-exist"
	result="$(ini_config_get ini-config/not-exist sect opt 2>&1)" || rc=$?
	assertEquals "Wrong return code: rc=$rc" "$rc" "1"
	assertEquals "$result" "$result" "$expect"
}
